﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;

public class ValueChange
{
    private List<ChangeClass> valueChangeQue;
    public ValueChange()
    {
        valueChangeQue = new List<ChangeClass>();
    }
    public ValueChange(List<ChangeClass> changeClasses)
    {
        valueChangeQue = changeClasses;
    }
    public void Enqueue(ChangeClass v)
    {
        valueChangeQue.Add(v);
    }
    public void Conduct()
    {
        foreach(var x in valueChangeQue)
        {
            x.Apply();
        }
    }
    public void Reset()
    {
        valueChangeQue = null;
    }
}



public class ChangeClass
{
    //public int changeType;   //1.Add 2.Delete 3.Set
    public virtual void Apply() { }
}
public class AddChangeClass : ChangeClass
{
    public TerrianManager.DataPack addData;
    public override void Apply()
    {
        TerrianManager.Instance.Create((ElementState)addData.data.elem, addData.pos);
    }

}
public class DeleteChangeClass : ChangeClass
{
    public uint id;
    public override void Apply()
    {
        TerrianManager.Instance.Delete(id);
    }
}
public class SetChangeClass : ChangeClass
{
    public uint id;
    public TerrianManager.DataPack toSet;
    public override void Apply()
    {
        TerrianManager.Instance.SetInfo(id, new BasicInfo (toSet.data.blood, toSet.data.defence, toSet.data.magicDefence, toSet.data.sharpness, toSet.data.mass, toSet.pos));
    }
}

